/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.brainstretch.models;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import org.brainstretch.models.actions.AnswerList;
import org.brainstretch.models.quizzes.Quiz;
import org.brainstretch.models.quizzes.QuizInstance;
import org.codehaus.jackson.annotate.JsonIgnore;

/**
 *
 * @author mrodaitis
 */
@XmlRootElement
@Entity
public class UserQuiz extends UserAction{

    @OneToMany(cascade=CascadeType.REMOVE, fetch= FetchType.EAGER)
    List<AnswerList> answers; 
    
    @ManyToOne
    private Quiz quiz;
    
    @OneToOne(cascade= CascadeType.ALL)
    private QuizInstance instance;
    
    private int points;
    
    private int pointsPossible;
    
    @Enumerated(EnumType.STRING)
    private CompletionStatus status;
    
    @Temporal(TemporalType.TIMESTAMP)
    private Date completionTime;
    
    public UserQuiz() {
        super();
        answers = new ArrayList<AnswerList>();
    }

    public UserQuiz(User user, QuizInstance instance, Quiz quiz) {
        super(user);
        answers = new ArrayList<AnswerList>();
        this.instance = instance;
        this.quiz = quiz;
        this.status = CompletionStatus.Incomplete;
    }

    public QuizInstance getInstance() {
        return instance;
    }

    public void setInstance(QuizInstance instance) {
        this.instance = instance;
    }

    public Quiz getQuiz() {
        return quiz;
    }

    public void setQuiz(Quiz quiz) {
        this.quiz = quiz;
    }

    public List<AnswerList> getAnswers() {
        return answers;
    }

    public void setAnswers(List<AnswerList> answers) {
        this.answers = answers;
    }

    public int getPoints() {
        return points;
    }

    public void setPoints(int points) {
        this.points = points;
    }

    public int getPointsPossible() {
        return pointsPossible;
    }

    public void setPointsPossible(int pointsPossible) {
        this.pointsPossible = pointsPossible;
    }

    public Date getCompletionTime() {
        return completionTime;
    }

    public void setCompletionTime(Date completionTime) {
        this.completionTime = completionTime;
    }

    public CompletionStatus getStatus() {
        return status;
    }

    public void setStatus(CompletionStatus status) {
        this.status = status;
    }
    
    
}
